package it.unive.taw;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class CircleOverlay extends Overlay {
	Context context;
	GeoPoint mPoint;
	int mRadius;

	public CircleOverlay(Context _context, GeoPoint _point, int _radius) {
		context = _context;
		mPoint = _point;
		mRadius = _radius;
	}

	public void draw(Canvas canvas, MapView mapView, boolean shadow) {

		super.draw(canvas, mapView, shadow);

		Projection projection = mapView.getProjection();

		Point pt = new Point();

		projection.toPixels(mPoint, pt);

		float circleRadius = projection.metersToEquatorPixels(mRadius);

		Paint innerCirclePaint;

		innerCirclePaint = new Paint();
		innerCirclePaint.setARGB(40, 70, 144, 193);
		innerCirclePaint.setAntiAlias(true);

		innerCirclePaint.setStyle(Paint.Style.FILL_AND_STROKE);

		canvas.drawCircle((float) pt.x, (float) pt.y, circleRadius,
				innerCirclePaint);
	}
}